/*
 * @Author: Superficial
 * @Date: 2021-07-01 14:24:15
 * @LastEditTime: 2022-06-05 11:01:26
 * @Description: 应用运行配置
 */
import path from 'path'
import yargs from 'yargs'
import { isDevEnv } from './app.environment'

const argv = yargs.argv as Record<string, string | void>

const ROOT_PATH = path.join(__dirname, '..')
const packageJSON = require(path.resolve(ROOT_PATH, 'package.json'))

export const APP = {
  PORT: 5090,
  ROOT_PATH,
  DEFAULT_CACHE_TTL: 60 * 60 * 24,
  MASTER: 'Superficial',
  NAME: 'NodePress',
  URL: 'https://zhangwurui.cn',
  ADMIN_EMAIL: '347106739@qq.com',
  FE_NAME: 'Superficial',
  FE_URL: 'https://zhangwurui.cn',
  STATIC_URL: 'https://static.zhangwurui.cn',
}

export const PROJECT = {
  name: packageJSON.name,
  version: packageJSON.version,
  author: packageJSON.author,
  site: APP.URL,
  description: packageJSON.description
}

export const CROSS_DOMAIN = {
  allowedOrigins: [
    'https://zhangwurui.cn',
    'https://www.zhangwurui.cn',
    'https://cdn.zhangwurui.cn',
    'https://chat.zhangwurui.cn',
    'https://ai.zhangwurui.cn',
    'https://admin.zhangwurui.cn',
  ],
  allowedReferer: 'zhangwurui.cn',
}

export const MONGO_DB = {

  uri: isDevEnv
    ? `mongodb://Superficial:zrui950312@47.115.225.243:5620/yijia?authSource=admin`
    : `mongodb://Superficial:zrui950312@mongodb:27017/yijia?authSource=admin`
}

export const REDIS = {
  namespace: argv.redis_namespace || 'nodepress',
  host: isDevEnv ? '47.115.225.243' : 'redis',
  port: isDevEnv ? 5621 : 6379,
  username: argv.redis_username || null,
  password: 'zrui950312',
  ttl: null,
  defaultCacheTTL: 60 * 60 * 24,
}

export const AUTH = {
  expiresIn: 3600, // 1 hour
  jwtSecret: 'nodepress', // JWT secret
  refreshExpiresIn: 3600 * 24 * 30, // 30 days
}

export const EMAIL = {
  service: '163',
  host: 'smtp.163.com',
  port: 465,
  account: '18171953034@163.com',
  password: 'QMNAFMVVMKPNCKGO',
  from: `"${APP.FE_NAME}" <18171953034@163.com>`,
  // admin: '347106739@qq.com',
}

export const COMMON_SERVICE = {
  aliyunIPAuth: '',
  juheIPAuth: '8d3aff4ed1531e65c3ba3414309dd843',
}

export const QINIU = {
  accessKey: '6lEYwVPcfmNGYBMWqgKZXl-isn80eojd1x7squfm',
  secretKey: 'Wol1jwZwhIW8qx4dJHlG3ctJJbVV9Ek6w0TMfu3t',
  media_bucket: 'periodical',
  pic_bucket: 'statices',
  use_https_domain: false,
  use_cdn_domain: false,
  API_KEY: 'sk-8eabb0f2ad26cd3ade090b90be366d4f98ccd3336d6c6eaa68c10ca34f4d9660'
}

export const BAIDU_INDEXED = {
  site: 'https://zhangwurui.cn',
  token: 'PdtIgAM22ycFgJL0',
}

// 微信
export const WECHAT = {
  appID: 'wx5f2a0c4e1b8d3e7d',
  appSecret: 'c0f2d1a3b4e5c6d7e8f9g0h1i2j3k4l5',
  callbackURL: 'http://localhost:3000/auth/wechat/callback',
  scope: 'snsapi_userinfo',
}


// 华为
export const HUAWEI = {
  CLIENT_ID: '6917583205779806322',
  CLIENT_SECRET: '49fccfa2aa6d486d2359645b516031c2231512b2addfa880df3ff3d5ece73acf'
}

// 高德地图
export const AMAP = {
  KEY: '936561edecf84b9cbbe0844ec174fd1b', // 高德地图API Key
}
